/*
 * my_debug.h
 *
 *  Created on: Aug 31, 2009
 *      Author: lius
 */

#ifndef MY_DEBUG_H_
#define MY_DEBUG_H_
/****************************DEBUG*****************************/
enum {
	EPOLL_DEBUG = 0,
	EPOLL_ERROR,
	EPOLL_INFO
};

#ifndef EPOLL_DBG_DATA
#define EPOLL_DBG_DATA 0
#endif

#ifndef EPOLL_DBG_STAT
#define EPOLL_DBG_STAT 0
#endif

#ifndef EPOLL_DBG_FUNC
#define EPOLL_DBG_FUNC 0
#endif

//#define _DEBUG

#ifdef _DEBUG
#define DEBUG_EPOLL(module, level, fmt...)\
do {\
	if(module && level >= 0){\
		if(level == EPOLL_DEBUG){\
			fprintf(stderr, "[%s][%05d][debug]: ", __FILE__, __LINE__);\
		}\
		else if(level == EPOLL_ERROR){\
			fprintf(stderr, "[%s][%05d][error]: ", __FILE__, __LINE__);\
		}\
		else if(level == EPOLL_INFO){\
			fprintf(stderr, "[%s][%05d][info ]: ", __FILE__, __LINE__);\
		}\
		fprintf(stderr, fmt);\
	}\
}while(0)
#else
#define DEBUG_EPOLL(module, level, fmt...)
#endif

#ifdef _DEBUG
#define FUNC_START(fmt...)\
do {\
	fprintf(stderr, "\n^^^^^^^^^^^^^  %s  ^^^^^^^^^^^^^\n", __func__);\
	fprintf(stderr, fmt);\
	fprintf(stderr, "\n");\
}while(0)

#define FUNC_RETURN(rt_value)\
do {\
	fprintf(stderr, "\nreturn value = %d\n", rt_value);\
	fprintf(stderr, "$$$$$$$$$$$$$  %s  $$$$$$$$$$$$$\n", __func__);\
	return rt_value;\
}while(0)

#else
#define FUNC_START(fmt...)
#define FUNC_RETURN(rt_value) \
do {\
	return rt_value;\
}while(0)
#endif


#endif /* MY_DEBUG_H_ */
